import request from '@/axios'
import type { CurdData } from './types'

export const getFieldEnumApi = (params: any) => {
  return request.get({ url: '/admin/logisticsRules/fieldEnum', params })
}

export const getListApi = (params: any) => {
  return request.get({ url: '/admin/logisticsRules', params })
}

export const getDetApi = (id: string): Promise<IResponse<CurdData>> => {
  return request.get({ url: '/admin/logisticsRules/' + id, params: { id } })
}

export const deleteDataApi = (ids: string): Promise<IResponse> => {
  return request.delete({ url: '/admin/logisticsRules', data: { ids } })
}

/**
 * 批量更新状态
 */
export const statusApi = (params: { ids: string; status: number }) => {
  return request.post({ url: '/admin/LogisticsRules/status', data: params })
}
export const logisticsFee = (data: Partial<CurdData>): Promise<IResponse> => {
  return request.post({ url: '/admin/logisticsRules/calculateFee', data })
}

export const saveDataApi = (data: Partial<CurdData>): Promise<IResponse> => {
  if (data.id) {
    return request.put({ url: '/admin/logisticsRules', data })
  } else {
    return request.post({ url: '/admin/logisticsRules', data })
  }
}
export const exportFileApi = (params = {}, filename: string) => {
  return request.exportFile({ url: '/admin/logisticsRules/export', params, filename })
}
